<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" href="/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Web3</title>
  </head>
  <body>
    <div id="app"></div>
    <script type="module" src="/src/main.ts"></script>
    <!-- <script src="https://solc-bin.ethereum.org/bin/soljson-v0.6.1+commit.e6f7d5a4.js"></script>
    <script>
      const soljson = window.Module
      let compile = null
      if ('_solidity_compile' in soljson) {
        compile = soljson.cwrap('solidity_compile', 'string', ['string', 'number'])
      }

      const input = {
        language: 'Solidity',
        sources: {
          'TodoList.sol': {
            content: `// SPDX-License-Identifier: MIT
pragma solidity ^0.6.1;
contract TodoList {
  struct Todo {
    string text;
    bool completed;
  }
  string public  name = "TODO-LF";
  uint256 public total;
  Todo[] public todos;

  function create(string calldata _text) external {
    todos.push(Todo({
      text: _text,
      completed: false
    }));
    total++;
  }

  function updateText(uint _index, string calldata _text) external {
    require(_index < todos.length, "undefind");
    todos[_index].text = _text;
  }

  function get(uint _index) external view returns(string memory, bool)  {
    require(_index < todos.length, "not todo");  
    Todo storage todo = todos[_index];
      return (todo.text, todo.completed);
  }

  function completed(uint _index) external  {
    require(_index < todos.length, "undefind");
    require(todos[_index].completed = true, "have completed");
    todos[_index].completed = true;
    total--;
  }
}
`,
          },
        },
        settings: {
          outputSelection: {
            '*': {
              '*': ['*'],
            },
          },
        },
      }

      const output = JSON.parse(compile(JSON.stringify(input)))
      console.log('[ output ] >', output)
    </script> -->
  </body>
</html>
